package com.hubujun.driverlicense.model;

import com.hubujun.driverlicense.DLCore;
import com.hubujun.driverlicense.util.Ln;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 题库列表
 * Created by Administrator on 2016/5/28 0028.
 */
public class QuestionListModel {
    public int error_code;
    public String reason;
    public List<QuestionModel> result = new ArrayList<>();

    public void copyFromJsonObject(JSONObject jsonObject) {
        if (jsonObject.has("error_code")) {
            this.error_code = error_code;
        }
        if (jsonObject.has("reason")) {
            this.reason = reason;
        }
        if (jsonObject.has("result")) {
            try {
                JSONArray jsonArray = jsonObject.getJSONArray("result");
                for (int i = 0; i < jsonArray.length(); i++) {
                    QuestionModel questionModel = new QuestionModel();
                    questionModel.copyFromJsonObject((JSONObject) jsonArray.get(i));
                    result.add(questionModel);
                }
            } catch (JSONException e) {
                Ln.e(e);
            }
        }
    }
}
